<!doctype html>
<html lang="zh-Hans" dir="ltr" class="plugin-pages plugin-id-default">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Docusaurus v2.0.1">
<link rel="search" type="application/opensearchdescription+xml" title="Knife4j" href="/opensearch.xml">

<!-- Google Tag Manager -->
    <script>!function(e,t,a,n,g){e[n]=e[n]||[],e[n].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var m=t.getElementsByTagName(a)[0],r=t.createElement(a);r.async=!0,r.src="https://www.googletagmanager.com/gtm.js?id=GTM-TKBX678",m.parentNode.insertBefore(r,m)}(window,document,"script","dataLayer")</script>
    <!-- End Google Tag Manager -->
<script src="/js/custom.js"></script>
<script src="/js/baidu.js"></script>
<script src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1589206801610969" async crossorigin="anonymous"></script><title data-rh="true">Knife4j · 集Swagger2及OpenAPI3为一体的增强解决方案. | Knife4j</title><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://doc.xiaominfo.com/"><meta data-rh="true" name="docusaurus_locale" content="zh-Hans"><meta data-rh="true" name="docusaurus_tag" content="default"><meta data-rh="true" name="docsearch:language" content="zh-Hans"><meta data-rh="true" name="docsearch:docusaurus_tag" content="default"><meta data-rh="true" property="og:title" content="Knife4j · 集Swagger2及OpenAPI3为一体的增强解决方案. | Knife4j"><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://doc.xiaominfo.com/"><link data-rh="true" rel="alternate" href="https://doc.xiaominfo.com/" hreflang="zh-Hans"><link data-rh="true" rel="alternate" href="https://doc.xiaominfo.com/" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://3CRIMRK623-dsn.algolia.net" crossorigin="anonymous"><script data-rh="true">function maybeInsertBanner(){window.__DOCUSAURUS_INSERT_BASEURL_BANNER&&insertBanner()}function insertBanner(){var n=document.getElementById("docusaurus-base-url-issue-banner-container");if(n){n.innerHTML='\n<div id="docusaurus-base-url-issue-banner" style="border: thick solid red; background-color: rgb(255, 230, 179); margin: 20px; padding: 20px; font-size: 20px;">\n   <p style="font-weight: bold; font-size: 30px;">Your Docusaurus site did not load properly.</p>\n   <p>A very common reason is a wrong site <a href="https://docusaurus.io/docs/docusaurus.config.js/#baseurl" style="font-weight: bold;">baseUrl configuration</a>.</p>\n   <p>Current configured baseUrl = <span style="font-weight: bold; color: red;">/</span>  (default value)</p>\n   <p>We suggest trying baseUrl = <span id="docusaurus-base-url-issue-banner-suggestion-container" style="font-weight: bold; color: green;"></span></p>\n</div>\n';var e=document.getElementById("docusaurus-base-url-issue-banner-suggestion-container"),s=window.location.pathname,r="/"===s.substr(-1)?s:s+"/";e.innerHTML=r}}window.__DOCUSAURUS_INSERT_BASEURL_BANNER=!0,document.addEventListener("DOMContentLoaded",maybeInsertBanner)</script><link rel="stylesheet" href="/assets/css/styles.66359a73.css">
<link rel="preload" href="/assets/js/runtime~main.e0db172c.js" as="script">
<link rel="preload" href="/assets/js/main.c059fb6e.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function e(e){document.documentElement.setAttribute("data-theme",e)}var t=function(){var e=null;try{e=localStorage.getItem("theme")}catch(e){}return e}();null!==t?e(t):window.matchMedia("(prefers-color-scheme: dark)").matches?e("dark"):window.matchMedia("(prefers-color-scheme: light)").matches?e("light"):e("dark")}()</script><div id="__docusaurus">
<div id="docusaurus-base-url-issue-banner-container"></div><div role="region"><a href="#" class="skipToContent_fXgn">跳到主要内容</a></div><nav class="navbar navbar--fixed-top navbarHideable_m1mJ"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/knife4j-light.svg" alt="" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/knife4j-dark.svg" alt="" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate">Knife4j</b></a><a class="navbar__item navbar__link" href="/docs/quick-start">文档</a><a class="navbar__item navbar__link changelog" href="/docs/middleware-sources">中间件</a><a class="navbar__item navbar__link changelog" href="/docs/oas">OAS规范</a><a class="navbar__item navbar__link changelog" href="/docs/action">实战指南</a><a class="navbar__item navbar__link changelog" href="/docs/changelog">更新日志</a><a class="navbar__item navbar__link changelog" href="/docs/faq">FAQ</a><div class="navbar__item dropdown dropdown--hoverable"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">旧版本</a><ul class="dropdown__menu"><li><a class="dropdown__link" target="_blank" href="/v2/index.html">2.0.9</a></li></ul></div></div><div class="navbar__items navbar__items--right"><div class="toggle_MW0i colorModeToggle_x44X"><button class="clean-btn toggleButton_yw5v toggleButtonDisabled_BJd7" type="button" disabled="" title="切换浅色/暗黑模式（当前为暗黑模式）" aria-label="切换浅色/暗黑模式（当前为暗黑模式）"><span><svg viewBox="0 0 13 12" fill="none" xmlns="http://www.w3.org/2000/svg" width="14" height="14" class="lightToggleIcon_SFTY"><g clip-path="url(#clip0_833_8168)"><path d="M6.59998 8.49999C7.98069 8.49999 9.09998 7.3807 9.09998 5.99999C9.09998 4.61928 7.98069 3.49999 6.59998 3.49999C5.21926 3.49999 4.09998 4.61928 4.09998 5.99999C4.09998 7.3807 5.21926 8.49999 6.59998 8.49999Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M6.59985 0.5V1.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M6.59985 10.5V11.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M2.7099 2.11L3.4199 2.82" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.77991 9.17999L10.4899 9.88999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M1.09998 6H2.09998" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11.0999 6H12.0999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M2.7099 9.88999L3.4199 9.17999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.77991 2.82L10.4899 2.11" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path></g><defs><clipPath id="clip0_833_8168"><rect width="12" height="12" fill="white" transform="translate(0.599976)"></rect></clipPath></defs></svg><svg viewBox="0 0 13 12" width="14" height="14" class="darkToggleIcon_ekgs"><path d="M10.7001 6.39501C10.6215 7.24611 10.3021 8.05721 9.77927 8.7334C9.25646 9.40959 8.55189 9.92291 7.748 10.2133C6.9441 10.5036 6.07414 10.5591 5.2399 10.3731C4.40565 10.187 3.64164 9.76728 3.03726 9.1629C2.43287 8.55851 2.01312 7.7945 1.8271 6.96026C1.64108 6.12602 1.6965 5.25605 1.98688 4.45216C2.27725 3.64826 2.79056 2.94369 3.46675 2.42088C4.14294 1.89808 4.95404 1.57866 5.80515 1.50001C5.30685 2.17414 5.06707 3.00473 5.12941 3.84071C5.19175 4.6767 5.55208 5.46254 6.14485 6.05531C6.73762 6.64808 7.52346 7.0084 8.35944 7.07074C9.19542 7.13308 10.026 6.8933 10.7001 6.39501Z" stroke="currentColor" fill="transparent" stroke-linecap="round" stroke-linejoin="round"></path></svg></span></button></div><a href="https://github.com/xiaoymin/swagger-bootstrap-ui" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link icon" title="View on GitHub">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a><div class="searchBox_ZlJk"><button type="button" class="DocSearch DocSearch-Button" aria-label="搜索"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">搜索</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div class="main-wrapper mainWrapper_z2l0"><header class="container heroBanner_qdFl"><div class="row padding-horiz--md"><div class="col col--12"><div class="relative_WWZZ row"><div class="col"><h1 class="tagline_Bqj_">Knife4j是一个集Swagger2 和 OpenAPI3<br>  为一体的增强解决方案</h1><h1 class="tagline_Bqj_"><span>Knife4j</span>是一个集<span>Swagger2</span> 和 <span>OpenAPI3<br> </span> 为一体的<span>增强</span>解决方案</h1></div></div><div class="row"><div class="col"><h2>帮助开发者快速聚合使用OpenAPI规范.</h2></div></div><div class="row"><div class="col"><div class="heroButtons_r52D"><a class="getStarted_D36F" href="/docs/quick-start">Get Started</a><a href="https://gitee.com/xiaoym/knife4j/stargazers" class="giteeStar_axBj"><img src="https://gitee.com/xiaoym/knife4j/badge/star.svg?theme=gvp" alt="star"></a><iframe src="https://ghbtns.com/github-btn.html?user=xiaoymin&amp;repo=knife4j&amp;type=star&amp;count=true&amp;size=large" frameborder="0" scrolling="0" width="170" height="30" title="GitHub"></iframe></div></div></div></div></div></header><section class="features_r5tH"><svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" viewBox="0 0 0 0" fill="none"><defs><linearGradient id="gradient-1" x1="26.667" y1="12" x2="14.28" y2="34.521" gradientUnits="userSpaceOnUse"><stop offset="0.001" stop-color="#FFB200"></stop><stop offset="0.081" stop-color="#FFB100"></stop><stop offset="0.156" stop-color="#FFAF02"></stop><stop offset="0.225" stop-color="#FEAB04"></stop><stop offset="0.291" stop-color="#FDA606"></stop><stop offset="0.353" stop-color="#FCA00A"></stop><stop offset="0.413" stop-color="#FB980E"></stop><stop offset="0.471" stop-color="#FA9013"></stop><stop offset="0.529" stop-color="#F98618"></stop><stop offset="0.587" stop-color="#F77B1E"></stop><stop offset="0.647" stop-color="#F56F24"></stop><stop offset="0.709" stop-color="#F3632B"></stop><stop offset="0.774" stop-color="#F25532"></stop><stop offset="0.844" stop-color="#EF473A"></stop><stop offset="0.918" stop-color="#ED3842"></stop><stop offset="0.999" stop-color="#EB284B"></stop></linearGradient><linearGradient id="gradient-2" x1="29.667" y1="0" x2="-1.809" y2="26.23" gradientUnits="userSpaceOnUse"><stop offset="0.001" stop-color="#FFB200"></stop><stop offset="0.081" stop-color="#FFB100"></stop><stop offset="0.156" stop-color="#FFAF02"></stop><stop offset="0.225" stop-color="#FEAB04"></stop><stop offset="0.291" stop-color="#FDA606"></stop><stop offset="0.353" stop-color="#FCA00A"></stop><stop offset="0.413" stop-color="#FB980E"></stop><stop offset="0.471" stop-color="#FA9013"></stop><stop offset="0.529" stop-color="#F98618"></stop><stop offset="0.587" stop-color="#F77B1E"></stop><stop offset="0.647" stop-color="#F56F24"></stop><stop offset="0.709" stop-color="#F3632B"></stop><stop offset="0.774" stop-color="#F25532"></stop><stop offset="0.844" stop-color="#EF473A"></stop><stop offset="0.918" stop-color="#ED3842"></stop><stop offset="0.999" stop-color="#EB284B"></stop></linearGradient></defs></svg><div class="container"><div class="row"><div class="col col--6"><div class="padding-horiz--md padding-bottom--md"><div class="featureLine_xeBu"><div class="featureIcon_pR2E"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32" alt="基础特性"><path d="M546.874 34.91a34.91 34.91 0 0 0-69.819 0v36.235C212.91 88.948 3.688 306.897.011 574.696c-.837 62.371 45.056 118.458 107.31 123.16a116.364 116.364 0 0 0 125.371-116.038H69.783c0-232.03 179.758-422.493 407.272-440.39v219.299a34.91 34.91 0 1 0 69.819 0V141.428c227.514 17.897 407.272 208.36 407.272 440.39H791.237a116.364 116.364 0 0 0 125.37 116.038c62.255-4.678 108.148-60.766 107.31-123.16-3.653-267.775-212.898-485.748-477.043-503.551V34.909zm33.978 580.932L558.533 637.3l5.306 30.487 5.656 32.442-30.79-15.941-26.74-13.848-26.74 13.848-30.79 15.941 5.655-32.419 5.306-30.51-22.319-21.458-23.11-22.178 32.768-4.701 30.139-4.306 13.637-27.229 15.454-30.86 15.453 30.883 13.66 27.206 30.139 4.306 32.745 4.7-23.11 22.18zm113.57-68.002-114.967-16.454-51.432-102.633a17.734 17.734 0 0 0-16.058-9.844 17.734 17.734 0 0 0-16.059 9.844l-51.41 102.633L329.53 547.84a17.57 17.57 0 0 0-9.961 30.091l83.223 79.872-19.642 112.803c-2.001 11.404 7.215 20.666 17.64 20.666 2.747 0 5.586-.628 8.332-2.094l102.89-53.202 102.818 53.248a17.792 17.792 0 0 0 8.332 2.071c10.472 0 19.642-9.262 17.687-20.666L621.16 657.826l83.223-79.871a17.57 17.57 0 0 0-9.937-30.092zm141.173 292.398a34.467 34.467 0 0 0-35.538 6.284 440.064 440.064 0 0 1-253.183 106.053V802.91a34.91 34.91 0 0 0-69.819 0v149.643a440.064 440.064 0 0 1-253.16-105.984 34.467 34.467 0 0 0-35.538-6.307c-29.952 11.637-32.465 41.053-7.959 61.882A509.882 509.882 0 0 0 511.965 1024c126.51 0 242.268-45.87 331.59-121.879 24.505-20.829 21.992-50.269-7.96-61.905z" fill="#f46729"></path></svg></div><h3>基础特性</h3></div><div><ul><li>兼容OpenAPI 2.0</li><li>兼容OpenAPI 3.0</li></ul></div></div></div><div class="col col--6"><div class="padding-horiz--md padding-bottom--md"><div class="featureLine_xeBu"><div class="featureIcon_pR2E"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32" alt="增强扩展"><path d="M598 327.7H426c-54.2 0-98.3 44.1-98.3 98.3v172c0 54.2 44.1 98.3 98.3 98.3h172c54.2 0 98.3-44.1 98.3-98.3V426c0-54.2-44.1-98.3-98.3-98.3zM614.4 598c0 8.9-7.5 16.4-16.4 16.4H426c-8.9 0-16.4-7.5-16.4-16.4V426c0-8.9 7.5-16.4 16.4-16.4h172c8.9 0 16.4 7.5 16.4 16.4v172z"></path><path d="M962.6 573.4h-81.9V450.6h81.9c22.5 0 41-18.4 41-41 0-22.5-18.4-41-41-41h-81.9v-90.7c0-74.2-60.4-134.6-134.6-134.6h-90.7V61.4c0-22.5-18.4-41-41-41-22.5 0-41 18.4-41 41v81.9H450.6V61.4c0-22.5-18.4-41-41-41s-41 18.4-41 41v81.9h-90.7c-74.2 0-134.6 60.4-134.6 134.6v90.7H61.4c-22.5 0-41 18.4-41 41 0 22.5 18.4 41 41 41h81.9v122.9H61.4c-22.5 0-41 18.4-41 41 0 22.5 18.4 41 41 41h81.9v90.7c0 74.2 60.4 134.6 134.6 134.6h90.7v81.9c0 22.5 18.4 41 41 41s41-18.4 41-41v-81.9h122.9v81.9c0 22.5 18.4 41 41 41 22.5 0 41-18.4 41-41v-81.9h90.7c74.2 0 134.6-60.4 134.6-134.6v-90.7h81.9c22.5 0 41-18.4 41-41-.2-22.6-18.6-41.1-41.1-41.1zM798.7 746.1c0 29-23.6 52.7-52.7 52.7H277.9c-29 0-52.7-23.6-52.7-52.7V277.9c0-29 23.6-52.7 52.7-52.7H746c29 0 52.7 23.6 52.7 52.7v468.2z"></path></svg></div><h3>增强扩展</h3></div><div><ul><li>基础ui组件(自定义文档、动态参数调试、I18n、接口排序、导出等)</li><li>基于Springfox框架+Swagger2规范的自动注入starter</li><li>基于Springdoc-openapi+OAS3规范的自动注入starter</li><li>提供对主流网关组件的统一聚合OpenAPI接口文档的解决方案</li></ul></div></div></div><div class="col col--6"><div class="padding-horiz--md padding-bottom--md"><div class="featureLine_xeBu"><div class="featureIcon_pR2E"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32" alt="框架适配"><path d="M862.08 699.392c-105.344 140.33-330.283 92.97-474.539 99.755 0 0-25.557 1.45-51.242 5.674 0 0 9.728-4.138 22.144-8.448 101.29-35.029 149.162-42.069 210.73-73.685C684.8 663.467 799.915 534.4 823.34 400.341 779.307 529.28 645.419 640.256 523.52 685.312c-83.413 30.805-234.325 60.757-234.368 60.757a225.28 225.28 0 0 1-6.101-3.242c-102.614-49.92-105.6-272.214 80.81-343.851 81.75-31.403 159.872-14.165 248.235-35.2 94.208-22.4 203.35-93.013 247.68-185.344 49.707 147.541 109.44 378.283 2.304 520.96zm1.792-566.613a393.045 393.045 0 0 1-45.44 80.64A425.899 425.899 0 0 0 512.64 84.096c-235.648 0-427.307 191.659-427.307 427.264A425.941 425.941 0 0 0 222.08 824.277l9.387 8.278a36.523 36.523 0 1 1 .042.042l6.358 5.632A424.96 424.96 0 0 0 512.64 938.667c225.195 0 410.155-175.275 425.984-396.459 11.69-108.33-20.31-245.888-74.752-409.43"></path></svg></div><h3>框架适配</h3></div><div><ul><li>适配兼容Spring MVC</li><li>适配兼容Spring Boot 2.2、2.3、2.4、2.5、2.6、2.7、3.0</li><li>适配兼容Spring WebFlux</li><li>基于SpringFox2.x版本提供Swagger2规范的增强扩展</li><li>基于Springdoc-openapi项目提供OAS3规范的增强扩展</li></ul></div></div></div><div class="col col--6"><div class="padding-horiz--md padding-bottom--md"><div class="featureLine_xeBu"><div class="featureIcon_pR2E"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32" alt="社区生态"><path d="M714.194 562.922c36.87-49.352 59.022-112.568 59.022-181.49C773.216 223.64 657.16 95.718 514 95.718c-143.164 0-259.218 127.922-259.218 285.714 0 68.922 22.152 132.138 59.022 181.49-67.698 23.222-116.626 86.314-116.626 161.366v114.284c0 94.682 77.37 171.434 172.81 171.434h288.02c95.44 0 172.812-76.752 172.812-171.434V724.288c.002-75.052-48.928-138.146-116.626-161.366zm-401.806-181.49c0-126.238 90.264-228.572 201.612-228.572s201.612 102.334 201.612 228.572c0 126.24-90.264 228.574-201.612 228.574S312.388 507.672 312.388 381.432zm460.828 442.856c0 71.008-63.302 128.57-141.388 128.57H396.174c-78.086 0-141.39-57.562-141.39-128.57v-85.712c0-60.738 46.47-111.344 108.748-124.79 42.452 33.46 94.3 53.364 150.47 53.364 56.168 0 108.016-19.904 150.468-53.364 62.278 13.446 108.748 64.052 108.748 124.79v85.712zM180.352 528.07c9.438-2.4 35.262-3.78 35.262-3.78s2.294-55.356 0-57.144c-47.058 0-85.406-138.792-86.404-171.428-3.86-126.18 95.104-196.358 201.612-228.57 24.724-7.476 34.514-48.34 0-57.14C187.94 18.914 71.604 137.924 71.604 295.718c0 68.924 22.152 132.138 59.022 181.492C62.93 500.428 14 563.52 14 638.574v114.282c0 94.682 19.766 171.432 115.208 171.432 41.016-.458 58.008-30.022 26.184-57.144-51.9 4.502-83.786-57.56-83.786-128.57v-85.71c-.002-60.744 46.468-111.346 108.746-124.794zm724.466-50.862c34.518-49.354 55.256-112.568 55.256-181.492 0-157.792-108.912-276.804-242.672-285.71-32.31 8.8-23.146 49.662 0 57.14 99.71 32.212 192.358 102.392 188.744 228.57-.934 32.636-36.836 171.428-80.89 171.428-2.148 1.786 0 57.144 0 57.144s24.176 1.38 33.012 3.78c58.302 13.448 101.806 64.05 101.806 124.792v85.71c0 71.01-29.85 133.072-78.438 128.57-29.794 27.122-13.886 56.684 24.512 57.144 89.348 0 107.854-76.75 107.854-171.432V638.57c-.002-75.05-45.808-138.142-109.184-161.362z"></path></svg></div><h3>社区生态</h3></div><div><ul><li>基于Servlet体系的微服务聚合中间件Knife4jAggregation</li><li>基于Spring Cloud Gateway网关聚合的微服务聚合中间件</li><li>独立运行的中间件Knife4jDesktop</li></ul></div></div></div><div class="col col--6"><div class="padding-horiz--md padding-bottom--md"><div class="featureLine_xeBu"><div class="featureIcon_pR2E"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32" alt="云原生"><path d="m435.37 612.267.3.426-42.625 102.955a220.63 220.63 0 0 1-88.533-110.805l109.995-18.646.17.214a18.773 18.773 0 0 1 20.651 25.856zm-35.54-90.838a18.773 18.773 0 0 0 7.38-32.256l.086-.469-83.67-74.837a219.435 219.435 0 0 0-31.146 138.88l107.264-30.934.085-.384zm48.853-84.48a18.773 18.773 0 0 0 29.824-14.378l.426-.214 6.4-111.786a219.477 219.477 0 0 0-128.426 61.525l91.605 64.981.17-.085zm32.426 117.334 30.848 14.89 30.806-14.805 7.68-33.28-21.334-26.581h-34.304l-21.333 26.581 7.637 33.237zm64-132.054a18.773 18.773 0 0 0 29.867 14.336l.341.128 91.051-64.554a221.355 221.355 0 0 0-127.659-61.526l6.315 111.574.085.042zm464.043 254.72L762.837 983.34a68.267 68.267 0 0 1-53.248 25.344l-395.136.128a68.267 68.267 0 0 1-53.205-25.43L14.805 677.035A67.541 67.541 0 0 1 1.707 619.86L89.6 237.781c4.608-20.053 18.133-36.864 36.821-45.781L482.347 21.888a68.523 68.523 0 0 1 59.093 0l356.053 170.027c18.688 8.917 32.214 25.77 36.822 45.781l87.978 382.08c4.608 20.053-.213 41.088-13.141 57.173zm-140.33-87.765c-1.793-.427-4.395-1.11-6.187-1.45-7.424-1.409-13.44-1.067-20.438-1.622-14.933-1.579-27.221-2.859-38.186-6.315-4.48-1.706-7.68-7.04-9.216-9.216l-8.576-2.517a275.2 275.2 0 0 0-4.48-99.499 275.84 275.84 0 0 0-39.936-92.288c2.218-2.005 6.4-5.674 7.552-6.784.341-3.84.042-7.808 4.01-12.032 8.406-7.893 18.944-14.421 31.702-22.272 6.058-3.584 11.648-5.845 17.706-10.325 1.366-1.024 3.243-2.645 4.694-3.797 10.24-8.15 12.586-22.187 5.248-31.403-7.339-9.216-21.59-10.07-31.787-1.92-1.45 1.152-3.413 2.645-4.736 3.755-5.717 4.949-9.259 9.813-14.08 14.933-10.496 10.667-19.2 19.541-28.715 25.984-4.138 2.39-10.197 1.579-12.928 1.408l-8.106 5.76a279.253 279.253 0 0 0-176.896-85.461l-.512-9.515c-2.774-2.645-6.102-4.907-6.955-10.667-.939-11.434.64-23.765 2.432-38.613.981-6.955 2.603-12.715 2.901-20.267.043-1.706-.042-4.224-.042-6.058 0-13.056-9.558-23.68-21.334-23.68-11.733 0-21.29 10.624-21.29 23.68l.042.597c0 1.75-.085 3.925 0 5.461.256 7.552 1.878 13.312 2.859 20.267 1.792 14.848 3.328 27.179 2.39 38.656a23.253 23.253 0 0 1-6.913 11.008l-.512 9.003a274.09 274.09 0 0 0-177.749 85.461 357.248 357.248 0 0 1-7.68-5.461c-3.84.512-7.68 1.706-12.672-1.238-9.515-6.4-18.219-15.274-28.715-25.941-4.821-5.12-8.32-9.984-14.037-14.89a114.816 114.816 0 0 0-4.736-3.755 25.344 25.344 0 0 0-14.848-5.632 20.523 20.523 0 0 0-16.981 7.509c-7.339 9.216-4.992 23.296 5.248 31.445l.298.214 4.438 3.541c6.058 4.48 11.605 6.784 17.664 10.325 12.757 7.894 23.296 14.422 31.701 22.272 3.243 3.499 3.84 9.643 4.267 12.288l6.826 6.102a275.712 275.712 0 0 0-43.52 192.256l-8.874 2.56c-2.347 3.072-5.675 7.85-9.174 9.258-10.965 3.456-23.296 4.694-38.186 6.272-6.998.598-13.014.256-20.48 1.664-1.579.299-3.84.854-5.675 1.28l-.17.086-.3.085c-12.586 3.03-20.65 14.592-18.047 25.941 2.602 11.392 14.89 18.304 27.52 15.574l.298-.043.427-.128 5.504-1.237c7.253-1.963 12.544-4.822 19.115-7.339 14.08-5.035 25.77-9.259 37.12-10.923 4.778-.384 9.813 2.944 12.288 4.31l9.258-1.579a277.333 277.333 0 0 0 122.88 153.43l-3.84 9.3c1.408 3.585 2.944 8.491 1.878 12.033-4.139 10.752-11.222 22.058-19.286 34.688-3.882 5.802-7.893 10.325-11.434 17.024-.854 1.578-1.92 4.053-2.731 5.717-5.461 11.733-1.45 25.216 9.088 30.293 10.581 5.12 23.723-.298 29.44-12.032v-.085c.853-1.664 1.963-3.84 2.645-5.419 2.987-6.912 4.011-12.842 6.144-19.541 5.632-14.165 8.747-29.013 16.512-38.272 2.134-2.56 5.547-3.499 9.174-4.48l4.821-8.747a275.328 275.328 0 0 0 196.65.512l4.523 8.192c3.67 1.195 7.68 1.792 10.923 6.614 5.803 9.898 9.77 21.632 14.592 35.84 2.133 6.656 3.157 12.586 6.187 19.498.682 1.579 1.834 3.84 2.645 5.504 5.675 11.776 18.859 17.152 29.44 12.032 10.539-5.034 14.55-18.56 9.088-30.293-.853-1.664-1.92-4.096-2.773-5.717-3.542-6.656-7.552-11.136-11.435-16.982-8.107-12.629-14.763-23.082-18.901-33.834-1.707-5.547.298-8.96 1.621-12.544-.768-.939-2.517-6.144-3.541-8.619a277.29 277.29 0 0 0 122.88-154.539c2.73.427 7.509 1.28 9.088 1.622 3.2-2.134 6.144-4.864 11.946-4.438 11.35 1.664 23.04 5.888 37.12 10.923 6.571 2.56 11.819 5.461 19.115 7.381 1.536.427 3.755.811 5.547 1.195l.384.128.298.043c12.672 2.73 24.918-4.182 27.52-15.574 2.56-11.349-5.461-22.912-18.048-25.941zM699.732 413.909l-83.2 74.496v.214a18.773 18.773 0 0 0 7.382 32.298l.128.427 107.776 31.061a221.824 221.824 0 0 0-4.608-71.424 222.208 222.208 0 0 0-27.478-67.114zm-171.221 227.2a18.645 18.645 0 0 0-17.237-9.898 18.773 18.773 0 0 0-15.872 9.941h-.086l-54.101 97.792a220.33 220.33 0 0 0 141.91.128l-54.187-97.963h-.427zm80.555-55.168a18.773 18.773 0 0 0-11.52 1.536 18.773 18.773 0 0 0-9.131 24.406l-.128.17 43.093 104.022a219.733 219.733 0 0 0 88.79-111.574l-110.934-18.773-.17.213z" fill="#f46729"></path></svg></div><h3>云原生</h3></div><div><ul><li>提供基于K8S+Docker的云原生的聚合OpenAPI文档的解决方案</li><li>简化Knife4j的使用及学习成本，一键部署&amp;集成&amp;使用</li></ul></div></div></div></div></div></section><section class="try_iMNP container"><div class="col"><img src="/images/website/knife4j-framework2.png"></div></section><section class="try_iMNP container"><div class="col"><div class="contributorsHeader_VXgX"><h1>Contributors</h1><div>Knife4j的发展离不开每一位Contributor的无私奉献～～！</div></div><div class="contributos_eJg6"><div class="contributor_eqdp"><a href="https://gitee.com/xiaoym" target="_blank"><div alt="八一菜刀" title="八一菜刀"><img src="/images/website/contributor/八一菜刀.png"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/linghengqian" target="_blank"><div alt="linghengqian" title="linghengqian"><img src="/images/website/contributor/linghengqian.jpeg"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/zuihou" target="_blank"><div alt="zuihou" title="zuihou"><img src="https://avatars.githubusercontent.com/u/8500410?v=4"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/galaxy-sea" target="_blank"><div alt="galaxy-sea" title="galaxy-sea"><img src="https://avatars.githubusercontent.com/u/30821411?v=4"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/bluesword12350" target="_blank"><div alt="bluesword12350" title="bluesword12350"><img src="https://avatars.githubusercontent.com/u/22535595?v=4"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/LLLeno" target="_blank"><div alt="LLLeno" title="LLLeno"><img src="https://avatars.githubusercontent.com/u/24690852?v=4"></div></a></div><div class="contributor_eqdp"><a href="https://gitee.com/perryzou" target="_blank"><div alt="perryzou" title="perryzou"><img src=""></div></a></div><div class="contributor_eqdp"><a href="https://gitee.com/newjava-cn" target="_blank"><div alt="newjava-cn" title="newjava-cn"><img src=""></div></a></div><div class="contributor_eqdp"><a href="https://gitee.com/tianchaohongyu" target="_blank"><div alt="tianchaohongyu" title="tianchaohongyu"><img src="https://portrait.gitee.com/uploads/avatars/user/507/1522755_tianchaohongyu_1578953588.png!avatar200"></div></a></div><div class="contributor_eqdp"><a href="https://gitee.com/miaoyinjun" target="_blank"><div alt="miaoyinjun" title="miaoyinjun"><img src="https://portrait.gitee.com/uploads/avatars/user/201/604134_miaoyinjun_1641539847.png!avatar200"></div></a></div><div class="contributor_eqdp"><a href="https://gitee.com/mhuang" target="_blank"><div alt="mhuang" title="mhuang"><img src=""></div></a></div><div class="contributor_eqdp"><a href="https://github.com/web-xiaxia" target="_blank"><div alt="web-xiaxia" title="web-xiaxia"><img src="/images/website/contributor/web-xiaxia.png"></div></a></div><div class="contributor_eqdp"><a href="https://gitee.com/bzw1204" target="_blank"><div alt="沐雨" title="沐雨"><img src="/images/website/contributor/沐雨.png"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/oIdmonk" target="_blank"><div alt="oIdmonk" title="oIdmonk"><img src="/images/website/contributor/oIdmonk.png"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/x403368945" target="_blank"><div alt="x403368945" title="x403368945"><img src="/images/website/contributor/x403368945.png"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/luoyunchong" target="_blank"><div alt="IGeekFan" title="IGeekFan"><img src="/images/website/contributor/IGeekFan.png"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/ColinZou" target="_blank"><div alt="ColinZou" title="ColinZou"><img src="/images/website/contributor/ColinZou.png"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/makefriend8" target="_blank"><div alt="MarsZhang" title="MarsZhang"><img src="/images/website/contributor/MarsZhang.png"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/rxxy" target="_blank"><div alt="rxxy" title="rxxy"><img src="/images/website/contributor/rxxy.png"></div></a></div><div class="contributor_eqdp"><a href="https://github.com/Hccake" target="_blank"><div alt="有猫饼" title="有猫饼"><img src="/images/website/contributor/有猫饼.png"></div></a></div><div class="contributor_eqdp"><a href="https://gitee.com/ghostg00" target="_blank"><div alt="ghostg00" title="ghostg00"><img src="/images/website/contributor/ghostg00.png"></div></a></div><div class="contributor_eqdp"><a href="https://gitee.com/jixq" target="_blank"><div alt="Simki" title="Simki"><img src="/images/website/contributor/Simki.png"></div></a></div><div class="contributor_eqdp"><a href="https://gitee.com/TaiXuZi" target="_blank"><div alt="太虚子" title="太虚子"><img src="/images/website/contributor/太虚子.png"></div></a></div><div class="contributor_eqdp"><a href="https://gitee.com/yuanlinwu" target="_blank"><div alt="歲月無聲" title="歲月無聲"><img src="/images/website/contributor/歲月無聲.png"></div></a></div><div class="contributor_eqdp"><a href="https://gitee.com/wll8" target="_blank"><div alt="小文" title="小文"><img src="/images/website/contributor/小文.png"></div></a></div></div></div></section><section class="try_iMNP container"><div class="col"><h2>快速开始(Spring Boot 2 + OpenAPI2)</h2><p>不同规范以及Spring Boot3 OpenAPI3的使用请移步<a href="docs/quick-start">详细文档</a></p><p>第一步：<a href="https://spring.io/guides/gs/spring-boot/">创建Spring Boot项目</a>并且在pom.xml中引入<a href="https://search.maven.org/search?q=g:com.github.xiaoymin">Knife4j的依赖包</a>，代码如下：</p><div class="language-xml codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-xml codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token comment" style="color:rgb(98, 114, 164)">&lt;!--引入Knife4j的官方start包,该指南选择Spring Boot版本&lt;3.0,开发者需要注意--&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">com.github.xiaoymin</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">knife4j-openapi2-spring-boot-starter</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">4.0.0</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>第二步：创建Swagger配置依赖，代码如下：：</p><div class="language-javascript codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-javascript codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">@</span><span class="token maybe-class-name">Configuration</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">@</span><span class="token maybe-class-name">EnableSwagger2WebMvc</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">class</span><span class="token plain"> </span><span class="token class-name">Knife4jConfiguration</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    @</span><span class="token function maybe-class-name" style="color:rgb(80, 250, 123)">Bean</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token plain">value </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">&quot;dockerBean&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">public</span><span class="token plain"> </span><span class="token maybe-class-name">Docket</span><span class="token plain"> </span><span class="token function" style="color:rgb(80, 250, 123)">dockerBean</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        </span><span class="token comment" style="color:rgb(98, 114, 164)">//指定使用Swagger2规范</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        </span><span class="token maybe-class-name">Docket</span><span class="token plain"> docket</span><span class="token operator">=</span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">new</span><span class="token plain"> </span><span class="token class-name">Docket</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token maybe-class-name">DocumentationType</span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token constant" style="color:rgb(189, 147, 249)">SWAGGER_2</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">apiInfo</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">new</span><span class="token plain"> </span><span class="token class-name">ApiInfoBuilder</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token comment" style="color:rgb(98, 114, 164)">//描述字段支持Markdown语法</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">description</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token string" style="color:rgb(255, 121, 198)">&quot;# Knife4j RESTful APIs&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">termsOfServiceUrl</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token string" style="color:rgb(255, 121, 198)">&quot;https://doc.xiaominfo.com/&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">contact</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token string" style="color:rgb(255, 121, 198)">&quot;xiaoymin@foxmail.com&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">version</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token string" style="color:rgb(255, 121, 198)">&quot;1.0&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">build</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token comment" style="color:rgb(98, 114, 164)">//分组名称</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">groupName</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token string" style="color:rgb(255, 121, 198)">&quot;用户服务&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">select</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token comment" style="color:rgb(98, 114, 164)">//这里指定Controller扫描包路径</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">apis</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token maybe-class-name">RequestHandlerSelectors</span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">basePackage</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token string" style="color:rgb(255, 121, 198)">&quot;com.github.xiaoymin.knife4j.controller&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">paths</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token maybe-class-name">PathSelectors</span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">any</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                </span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">build</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token punctuation" style="color:rgb(248, 248, 242)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        </span><span class="token keyword control-flow" style="color:rgb(189, 147, 249);font-style:italic">return</span><span class="token plain"> docket</span><span class="token punctuation" style="color:rgb(248, 248, 242)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token punctuation" style="color:rgb(248, 248, 242)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token punctuation" style="color:rgb(248, 248, 242)">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>第三步:新建一个接口Controller类，如下：</p><div class="language-javascript codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-javascript codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">@</span><span class="token function maybe-class-name" style="color:rgb(80, 250, 123)">Api</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token plain">tags </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">&quot;首页模块&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">@</span><span class="token maybe-class-name">RestController</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">class</span><span class="token plain"> </span><span class="token class-name">IndexController</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    @</span><span class="token function maybe-class-name" style="color:rgb(80, 250, 123)">ApiImplicitParam</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token plain">name </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">&quot;name&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain">value </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">&quot;姓名&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain">required </span><span class="token operator">=</span><span class="token plain"> </span><span class="token boolean">true</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    @</span><span class="token function maybe-class-name" style="color:rgb(80, 250, 123)">ApiOperation</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token plain">value </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">&quot;向客人问好&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    @</span><span class="token function maybe-class-name" style="color:rgb(80, 250, 123)">GetMapping</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token string" style="color:rgb(255, 121, 198)">&quot;/sayHi&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">public</span><span class="token plain"> </span><span class="token maybe-class-name">ResponseEntity</span><span class="token operator">&lt;</span><span class="token known-class-name class-name">String</span><span class="token operator">&gt;</span><span class="token plain"> </span><span class="token function" style="color:rgb(80, 250, 123)">sayHi</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token plain">@</span><span class="token function maybe-class-name" style="color:rgb(80, 250, 123)">RequestParam</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token plain">value </span><span class="token operator">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">&quot;name&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token known-class-name class-name">String</span><span class="token plain"> name</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token punctuation" style="color:rgb(248, 248, 242)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        </span><span class="token keyword control-flow" style="color:rgb(189, 147, 249);font-style:italic">return</span><span class="token plain"> </span><span class="token maybe-class-name">ResponseEntity</span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">ok</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token string" style="color:rgb(255, 121, 198)">&quot;Hi:&quot;</span><span class="token operator">+</span><span class="token plain">name</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token punctuation" style="color:rgb(248, 248, 242)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token punctuation" style="color:rgb(248, 248, 242)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token punctuation" style="color:rgb(248, 248, 242)">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>万事俱备，启动Spring Boot项目，浏览器访问Knife4j的文档地址即可查看效果</p><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">http://localhost:8080/doc.html</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div></div></section><div class="container"><div class="row"><div class="col text--center padding-top--lg padding-bottom--xl"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="200" viewBox="0 0 200 200" fill="none" class="bottomLogo_ktCI"><defs><pattern id="b" patternContentUnits="objectBoundingBox" width="1" height="1"><use transform="scale(.005)" xlink:href="#a"></use></pattern><image id="a" width="200" height="200" xlink:href=""></image></defs><path fill-rule="evenodd" style="fill:url(#b)" d="M0 200h200V0H0v200Z"></path></svg></div></div></div></div><footer class="footer"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">文档指南</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/docs/quick-start">文档</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/community/simple-demo">示例</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/changelog">更新日志</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/upgrading/upgrading-to-v4">升级到v4.0</a></li></ul></div><div class="col footer__col"><div class="footer__title">社区</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://gitter.im/knife4j/knife4j" target="_blank" rel="noopener noreferrer" class="footer__link-item">Gitter<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://www.oschina.net/question/tag/swagger-bootstrap-ui" target="_blank" rel="noopener noreferrer" class="footer__link-item">开源中国<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><div class="col footer__col"><div class="footer__title">关注公众号</div><ul class="footer__items clean-list"><li class="footer__item"><img src="/images/website/qrcode.jpg" width="150"></li></ul></div><div class="col footer__col"><div class="footer__title">更多</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://docusaurus.io" target="_blank" rel="noopener noreferrer" class="footer__link-item">Docusaurus<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://gitee.com/xiaoym/knife4j" target="_blank" rel="noopener noreferrer" class="footer__link-item">Gitee<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://github.com/xiaoymin/swagger-bootstrap-ui" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Apache License 2.0 | Copyright © 2018-2023-八一菜刀 浙ICP备18027673号-1 </div></div></div></footer></div>
<script src="/assets/js/runtime~main.e0db172c.js"></script>
<script src="/assets/js/main.c059fb6e.js"></script>
<!-- Google Tag Manager (noscript) -->
    <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TKBX678" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    <!-- End Google Tag Manager (noscript) --></body>
</html>